<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Professional extends Model
{
    protected $table = 'c_professionals';

    /**
     * 获取全部医生职称
     * @return Professional[]|\Illuminate\Database\Eloquent\Collection
     */
    public function getOptions()
    {
        $options = $this->select('id', 'name as text')->get();
        $selectOption = [];
        foreach ($options as $option) {
            $selectOption[$option->id] = $option->text;
        }
        return $selectOption;
    }
    /**获取分类名称
     * @param $id
     * @return mixed
     */
    public function getName($id)
    {
        $res = $this->select('name')->find($id);
        if (!empty($res)) {
            return $res->name;
        } else {
            return '';
        }
    }
}
